<?php

namespace App\Dao\System;

use App\Model\System\SystemRoles;
use Yj\Daos\BaseDao;
use Hyperf\Database\Model\Builder;
use Yj\Daos\Verify;

/**
 * @var SystemRoles
 */
class SystemRolesDao extends BaseDao
{
    public function DaoWhere(array $params)
    {
        return $this->getDaoQuery($params, function (Verify $verify) {
            $verify('id', function (Builder $query, $id) {
                $query->where('id', $id);
            });
        });
    }

    public function lists(\Hyperf\Utils\Collection|array $param = [])
    {
        return $this->getList();
    }

    public function add(\Hyperf\Utils\Collection $params)
    {
        return $this->create($params->toArray());
    }

    public function del(int $roles_id)
    {
        return $this->where('id', $roles_id)->delete();
    }

    public function edit($roles_id, $data)
    {
        $dao = $this->where('id', $roles_id)->first();
        $dao->fill($data->toArray());
        return $dao->save();
    }

}